/*******************************************************************************
 * Copyright (c) 2008, 2009 Fabio Mauro - Alberto Terraneo.
 * Permission is granted to copy, distribute and/or modify this document
 * under the terms of the GNU Free Documentation License, Version 1.2
 * or any later version published by the Free Software Foundation.
 *     
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied 
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 * See the GNU Free Documentation License for more details.
 *     
 * You should have received a copy of the GNU Free Documentation 
 * License along with this distribution; if not, send a email to authors:
 * aterraneo <at> users.sourceforge.net
 * bigmoby09 <at> users.sourceforge.net
 *******************************************************************************/
package it.blueocean.acanto.model.constants;

import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;

public enum TipoUnitaDiMisura
{
	PZ("Pezzi"), DZ("Dozzine"), g("Grammi"), LT("Litri"), KG("Chilogrammi"), QT("Quintali");

	private final String valore;

	TipoUnitaDiMisura(String valore)
	{
		this.valore = valore;
	}

	public static List<TipoUnitaDiMisura> getListTipiUnitaDiMisura()
	{
		return new ArrayList<TipoUnitaDiMisura>(Collections.synchronizedSet(EnumSet.allOf(TipoUnitaDiMisura.class)));
	}

	public String getValore()
	{
		return valore;
	}

	public static List<String> getListStringTipiUnitadiMisuraValues()
	{
		List<String> resultList = new ArrayList<String>();
		List<TipoUnitaDiMisura> list = TipoUnitaDiMisura.getListTipiUnitaDiMisura();

		for (TipoUnitaDiMisura tipiUnitaDiMisura : list)
		{
			resultList.add(tipiUnitaDiMisura.getValore());
		}

		return resultList;
	}

	public static TipoUnitaDiMisura getFromValue(String unitaMisuraValue)
	{
		List<TipoUnitaDiMisura> list = getListTipiUnitaDiMisura();
		for (TipoUnitaDiMisura item : list)
		{
			if (item.valore.equalsIgnoreCase(unitaMisuraValue))
				return item;
		}
		return null;
	}
}
